home *** CD-ROM | disk | FTP | other *** search
/ Unreal Tournament Game Programming for Teens / UnrealTournamentGameProgrammingForTeens.iso / Chapter Files / Chapter10 / DiscoLightTriggerC.txt < prev    next >
Encoding:
Text File  |  2006-11-05  |  2.7 KB  |  78 lines

  1. //================================================================
  2. // DiscoLightTriggerC.
  3. // See DiscoLightTriggerC.txt
  4. //================================================================
  5. class DiscoLightTriggerC extends Trigger placeable;
  6. // #1
  7. var private bool Toggle;
  8. const QUOTES = 10;
  9. var private string GrouchoSays[QUOTES];
  10. // #2
  11. function PostBeginPlay(){
  12.      SetQuotes();
  13. }
  14. function Touch( Actor Other )
  15. {
  16.      local TriggerLight SomeTriggerLight;
  17.      Message = GetMessage();
  18.      if ( ReTriggerDelay > 0 ){
  19.        if ( Level.TimeSeconds - TriggerTime < ReTriggerDelay ){
  20.               return;
  21.           }
  22.        TriggerTime = Level.TimeSeconds;
  23.      }// end if
  24.      
  25.      foreach DynamicActors( class 'TriggerLight', SomeTriggerLight, Event){
  26.         SomeTriggerLight.Trigger(Other, Other.Instigator);
  27.      } 
  28.      // Access the message value
  29.      if( (Message != "") && (Other.Instigator != None) ){
  30.           // Send a string message to the touching object.
  31.           Other.Instigator.ClientMessage( Message );
  32.      }
  33.      if (RepeatTriggerTime > 0){
  34.           SetTimer(RepeatTriggerTime, false);
  35.      }
  36. }// end Touch
  37. // #3 Provide a message
  38. private function string GetMessage(){
  39.      local string Quote;
  40.      if(Toggle == False){
  41.          // Quote = "Change the lights!";
  42.          Quote = GetQuote();
  43.      }else{
  44.          Quote = "";
  45.      }  
  46.      return Quote;
  47. }
  48. // #4
  49. private function string GetQuote(){
  50.      local int QuoteNumber;
  51.      local string WhatHeSays;
  52.      QuoteNumber = Rand(QUOTES);
  53.      if(QuoteNumber < QUOTES ){
  54.          WhatHeSays = GrouchoSays[QuoteNumber];
  55.      }
  56.      return WhatHeSays;
  57. }
  58. // #5 
  59. private function SetQuotes(){ 
  60.    GrouchoSays[0] = "Either he's dead or my watch has stopped. ";
  61.    GrouchoSays[1] = "And I want to thank you for all the " $
  62.                     "enjoyment you've taken out of it. "; 
  63.    GrouchoSays[2] = "All people are born alike - " $
  64.                     "except Republicans and Democrats. "; 
  65.    GrouchoSays[3] = "I don't care to belong to a club that " $
  66.                     "accepts people like me as members. "; 
  67.    GrouchoSays[4] = "I must confess, I was born at a very early age. "; 
  68.    GrouchoSays[5] = "I worked my way up from nothing "$
  69.                     "to a state of extreme poverty. ";
  70.    GrouchoSays[6] = "Military intelligence is a contradiction in terms. "; 
  71.    GrouchoSays[7] = "No man goes before his time - " $
  72.                     "unless the boss leaves early. ";
  73.    GrouchoSays[8] = "The secret of life is honesty and fair dealing." $
  74.                     " If you can fake that, you've got it made. ";
  75.    GrouchoSays[9] = "A hospital bed is a parked" $ 
  76.                     " taxi with the meter running. ";
  77. }   
  78.